﻿using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fluent
{
    [TestClass]
    public class FluentTests
    {
        public TestContext TestContext { get; set; }
        protected dynamic DynamicContext { get; private set; }

        public FluentTests()
        {
            this.DynamicContext = new ExpandoObject();
        }

        protected Browser Browser { get; set; }
        protected EBrowserType? BrowserType { get; set; }

        [TestInitialize]
        public void TestInit()
        {
            if (!BrowserType.HasValue)
            {
                BrowserType = EBrowserType.Chrome;
            }

            Browser = BrowserLoader.Load(BrowserType.Value, maxWindow: true)
                .SetTestContext(TestContext);
        }

        [TestCleanup]
        public void TestCleanUp()
        {
            if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
            {
                Browser.Snapshot(SnapshotType.FullPage);
            }

            Browser.Close();
            Browser.Quit();
        }

        protected void RunCase(Action caseActions)
        {
            throw new NotImplementedException();
        }
    }
}